package com.lottery.ruok.lottrey.chat.model.prize.message;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableString;
import android.view.View;
import android.view.ViewGroup;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.activity.GiveRewardDetailActivity;
import com.lottery.ruok.lottrey.chat.model.prize.message.view.PrizeView;

import io.rong.imkit.model.ProviderTag;
import io.rong.imkit.model.UIMessage;
import io.rong.imkit.widget.provider.IContainerItemProvider;
import io.rong.imlib.model.Message;

/**
 * Created by Beyond on 2016/12/5.
 */
@ProviderTag(messageContent = PrizeMessage.class, showProgress = false, showReadState = true)
public class PrizeMessageItemProvider extends IContainerItemProvider.MessageProvider<PrizeMessage> {
    private final static String TAG = "ContactMessageItemProvider";
private Context context;
    public PrizeMessageItemProvider() {
    }

    @Override
    public View newView(Context context, ViewGroup group) {
        PrizeView redPacketView = new PrizeView(context);
        this.context=context;
        return redPacketView;
    }

    @Override
    public void bindView(View v, int position, final PrizeMessage content, final UIMessage message) {
        if (v instanceof PrizeView) {
            PrizeView view = (PrizeView) v;
            view.setData(content);
            if (message.getMessageDirection() == Message.MessageDirection.RECEIVE) {
                view.setRedPacketBackgroundResource(R.mipmap.shang_left);
            } else {
                view.setRedPacketBackgroundResource(R.mipmap.shang_right);
            }
        }

    }

    @Override
    public Spannable getContentSummary(final PrizeMessage PrizeMessage) {
        return null;
    }

    @Override
    public Spannable getContentSummary(Context context, final PrizeMessage PrizeMessage) {

        return new SpannableString("[ 打赏 ]");
    }

    @Override
    public void onItemClick(View view, int position, PrizeMessage content, UIMessage message) {

    }
}
